<template>
  <a-tree
    v-model="checkedKeys"
    :checkable="true"
    :selected-keys="selectedKeys"
    :expandedKeys="expandedKeys"
    :autoExpandParent="true"
    :tree-data="treeData"
    :multiple="true"
    @expand="onExpand"
    @check="onCheck"
  />
</template>

<script>
export default {
  name: 'GenerateProductOrderSelectStep',
  data() {
    return {
      treeData: [],
      checkedKeys: [],
      selectedKeys: [],
      expandedKeys: []
    }
  },
  methods: {
    onExpand(expandedKeys) {
      console.log('expandedKeys', expandedKeys)
      console.log('this.expandedKeys', this.expandedKeys)
      this.expandedKeys = expandedKeys
    },
    onCheck(checkedKeys) {
      // 过滤掉树节点的层次信息，如0-1,0-1-1,0-1-2
      let newCheckedKeys = [...checkedKeys].filter(value => !this.expandedKeys.includes(value))
      this.$emit('check', newCheckedKeys)
    }
  }
}
</script>

<style scoped></style>
